package com.skillworld.webapp.model.user;

import java.util.Collection;

import com.skillworld.webapp.model.department.rank.DeptRank;
import com.skillworld.webapp.model.department.rank.Rank;

public class Medals 
{
    private int novice;
    private int beginner;
    private int intermediate;
    private int master;
    private int masterCoach;
    
    
    Medals(Collection<DeptRank> deptRanks)
    {
        int gradesPerLevel = Rank.MAX_GRADE+1;
        
        novice = 0;
        beginner = 0;
        intermediate = 0;
        master = 0;
        masterCoach = 0;
        for (DeptRank r : deptRanks)
        {
            int level = r.getLevel();
            
            if (level <= Rank.BEGINNER.getBaseLevel())
            { novice += level; }
            else if (level <= Rank.INTERMEDIATE.getBaseLevel())
            {
                novice += gradesPerLevel;
                beginner += level - Rank.BEGINNER.getBaseLevel();
            }
            else if (level <= Rank.MASTER.getBaseLevel())
            {
                novice += gradesPerLevel;
                beginner += gradesPerLevel;
                intermediate += level - Rank.INTERMEDIATE.getBaseLevel();
            }
            else if (level <= Rank.MASTER_COACH.getBaseLevel())
            {
                novice += gradesPerLevel;
                beginner += gradesPerLevel;
                intermediate += gradesPerLevel;
                master += level - Rank.MASTER.getBaseLevel();
            }
            else
            {
                novice += gradesPerLevel;
                beginner += gradesPerLevel;
                intermediate += gradesPerLevel;
                master += gradesPerLevel;
                masterCoach += level - Rank.MASTER_COACH.getBaseLevel();
            }
        }
    }
    
    
    public int getNovice() 
    {
        return novice;
    }
    
    public int getBeginner() 
    {
        return beginner;
    }
    
    public int getIntermediate() 
    {
        return intermediate;
    }
    
    public int getMaster() 
    {
        return master;
    }
    
    public int getMasterCoach() 
    {
        return masterCoach;
    }
}
